﻿Ext.ns("TRust");
var trdata ;
var listreport;
var userID;
function Login(cUser) { 
	cTarget='NA';
			Ext.Ajax.request({
				url: "./Trustee.mvc/getTrustee",
				params: {
			
				UserID: cUser,
				Pwd: 'NA'                      // parameter untuk url yang dituju (fungsi didalam controller)
				},
				success: function(o) {
					var cst = Ext.decode(o.responseText);
					
					LoadModules(cst.ListTrustee);
					listreport=cst.ListReport;
					//GetReportList(cst.ListTrustee[0].Mod_Group)
				}

			});

};



function LoadModules(records){
	var group;
	var pnl;
	var cHtm;
	var i;
	group='';

	for(var i = 0; i < records.length; i++)
		{
		var x = records[i];
		
		if (group !== x.Mod_Group)
			{
				if (pnl != undefined){ 

				cHtm += '</table></p></div>';
				pnl.html=cHtm;

				menuBarPanel.items.add(pnl);
				}
				group=x.Mod_Group;
				pnl = GetPanelMenu(x);

				cHtm = '<div align=center><img src="images/default/s.gif" height=5>'
				cHtm += '<table class="coolmenu" border=0 bordercolor="ivory" cellpadding=20 cellspacing=0 >'
				cHtm +=x.Mod_URL
				
			}
		else
			{

				cHtm+=x.Mod_URL;
			}
				
				
		};
	cHtm += '</table></p></div>';
	pnl.html=cHtm;
	menuBarPanel.items.add(pnl);
	menuBarPanel.doLayout();
};

function GetPanelMenu(x){
	var pnl = new Ext.Panel({
			title: x.Mod_Group,
			align: 'center',
		    iconCls: x.Mod_Img,
			autoScroll:true,
			cls: 'empty',
			listeners:{ 
				beforeexpand: function(a,b){
				//GetReportList(x.Mod_Group);
				}
			},
			bodyStyle: 'background:url(images/customer/bg_leftmenu_customer2.png) repeat-y;#ae1515;'
			
			
			 	});
	return pnl;
};


function GetReportList(cgroup)
{
var cHtm;
for(var i = 0; i < listreport.length; i++)
		{
		var x = listreport[i];
		
		if (cgroup === x.Mod_Group)
		{
				
				cHtm =  '<table id="tbl1" cellpadding="0" cellspacing="3" border="0" width=100% height=100% class="rptmenu">';
				cHtm += '<tr height=80%><td valign=top>';
				cHtm += '<table id="tbl2"  cellpadding="0" cellspacing="1" border="0" width=100% class="rptmenu">';
				cHtm += x.Htm;
			
				cHtm += '<tr><td><img src="../images/default/s.gif" height=300 width=1 border=1></td></tr>';
				cHtm += '</table>';
				cHtm += '</td></tr>';
			
				cHtm += '<tr height=20%><td id="boxdescription" valign="top" class="text-desc">&nbsp';
				cHtm += '</td></tr>';
				cHtm += '</table>';
				
			

				 document.getElementById("Report-content").innerHTML=cHtm;				 
				break;
			
		}
		
				
		};
		tabInfoPanel.doLayout();
		
};